package com.util;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public Queue queue() {
        return new Queue(Constants.QUEUE_NAME,false,false,false,null);
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(Constants.EXCHANGE_NAME,false,false,null);
    }

    @Bean
    public Binding binding(Queue queue, DirectExchange directExchange) {
        return BindingBuilder.bind(queue).to(directExchange).with(Constants.ROUTING_KEY);
    }
}
